

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/plugins/layui/css/layui.css?v=${.Config.basic.version}" media="all">
    <link rel="stylesheet" href="/layuiadmin/style/admin.css?v=${.Config.basic.version}" media="all">
    <link rel="stylesheet" href="/plugins/layui/css/style.css?v=${.Config.basic.version}" media="all">

    <link rel="stylesheet" href="/plugins/layui/css/add.css?v=${.Config.basic.version}" media="all">
    <link rel="stylesheet" href="/plugins/layui/css/sm.css?v=${.Config.basic.version}" media="all">
</head>
<body>

<div id="tab" class="layui-tab layui-tab-brief" lay-filter="mytab">
    <ul class="layui-tab-title">
    </ul>
    <div class="layui-tab-content">
    </div>
</div>

<script src="/plugins/layui/layui.js"></script>
<script>
    var table=null;
    var form=null;
    var element=null;

    var sys_roles=null;
    var token = window.localStorage.getItem("token");
    var user_info=JSON.parse(window.localStorage.getItem("user_info"));
    token = 'Bearer ' + token;
    layui.config({
        base: '../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table','form','element'], function(){
        $ = layui.$;
        form = layui.form;
        table = layui.table;
        element = layui.element;
        $('#tab').height($(window).height()-20);


        $.ajax({
            type: 'POST',
            url: '/Sys/GetFrames',
            data: {func_id:"rbac_allocate"},
            beforeSend: function(request) {
                request.setRequestHeader("Authorization", 'Bearer '+window.localStorage.getItem("token"));
            },
            dataType: "json",
            success: function (data) {
                //console.info(data)
                for(var i=0;i<data.length;i++){
                    element.tabAdd('mytab', {
                        title: data[i].name
                        ,content: "<iframe id='"+data[i].id+"' class='layui-col-xs12' to=\""+data[i].url+"\" frameborder=\"0\"></iframe> "
                        ,id: data[i].id
                    });
                    if(data[i].default_select==1){
                        element.tabChange('mytab', data[i].id); //切换到默认勾选
                        $("#"+data[i].id).attr("src",data[i].url);
                    }
                }
                //动态记载frame
                element.on('tab(mytab)', function(d){
                    console.log(this);
                    //console.log(data);
                    var id=$(this).attr("lay-id");
                    for(var i=0;i<data.length;i++){
                        if(data[i].id==id){
                            var frame=$("#"+data[i].id);
                            if(frame.attr("src")){

                            }else{
                                frame.attr("src",data[i].url);
                            }

                        }
                    }
                });

                resizeFrame();
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                layer.msg('加载页面失败');
            }
        });

        $(window).resize(function () {
            //console.info('resize')
            resizeFrame();
        });
        function resizeFrame() {
            $('#tab').height($(window).height()-20);
            $('iframe').height($(window).height()-70);
        }

    });

</script>
<script src="../js/check_screen.js?v=${.Config.basic.version}"></script>

</body>
</html>

